<html>
<head>
	<meta charset="UTF-8">
	<title>流程基本信息列表</title>
	<link id="easyuiTheme" href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
	<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
	<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
	<script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
	<script src="../../ffres/dict/all.js" type="text/javascript"></script>
	<link href="../../static/easyui/themes/frameless.css" rel="stylesheet" type="text/css"/>

	<a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<script type="text/javascript">


	function doAdd(){
		var subsCode = $.getUrlParam('subsCode');
		JLEUtil.createModalWin('新增', 'BpmBaseInfoAdd.html?bpmType=2&subsCode='+subsCode);
	}

	function doUpdate() {
		var row = $('#dg').datagrid('getSelected');
		if (row){
			JLEUtil.createModalWin('修改', 'BpmBaseInfoUpdate.html?' + 'bpmId=' + row.bpmId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function bpmTest() {
		var row = $('#dg').datagrid('getSelected');
		if (row){
			JLEUtil.createModalWin('修改', 'BpmTestParamConf.html?' + 'bpmId=' + row.bpmId+ '&bpmName=' + row.bpmName);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doEdit() {
		var row = $('#dg').datagrid('getSelected');
		if (row){
			var url = 'BpmBaseInfoUpdateNewTab.html?&bpmId='+row.bpmId;
			JLUtil.linkNewPage(url);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doDelete(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.messager.confirm('删除提示', '你确定要删除这条记录?', function(r){
				if (r){
					var jsonData = JSON.parse('{'+'"bpmId":"' + row.bpmId + '"'+'}');
					$.restfulDelete('../../api/bpm/base/info', jsonData, function(data) {
						$.messager.alert('提示','记录删除成功!','info');
						$('#dg').datagrid('reload');
					});
				}
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doView(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('详情','BpmBaseInfoView.html?' + '&bpmId=' + row.bpmId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function queryList(){
		var subsCode = $.getUrlParam("subsCode");
		var bpmCode=document.getElementById("bpmCode").value;
		var bpmName=document.getElementById("bpmName").value;
		$('#dg').datagrid({
			queryParams: {
				subsCode: subsCode,
				bpmCode:bpmCode,
				bpmName:bpmName
			}
		});
		var bpmType = 2;
		$('#dg').datagrid({url : '../../api/bpm/base/infos/'+bpmType})
	}

	function reloadList(){
		$('#dg').datagrid('reload');
		JLEUtil.closewin();
	};
	$(function(){
		var subsCode = $.getUrlParam("subsCode");
		var categoryTag = $.getUrlParam("categoryTag");
		$('#dg').datagrid({
			queryParams: {
				subsCode: subsCode,
				LatestState: 'Y'
			}
		});
		var bpmType = 2;
		$('#dg').datagrid({url : '../../api/bpm/base/infos/'+bpmType})
	});

	//发布审批流程
	function doPublish() {
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.messager.confirm('提示', '是否确定发布审批流程?', function(r){
				if (r){
					$.ajax({
						type: 'POST',
						url: '../../api/wfi/flow/publish',
						data: JSON.stringify(row),
						contentType:"application/json;charset=utf-8",
						dataType:"json",
						async:false,
						success: function(data) {
							if(data){
								reloadList();
								$.messager.alert('提示','流程发布成功!','info');
							}else{
								$.messager.alert('错误','流程发布失败!','erro');
							}
						}
					});
				}
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}


	//查看流程版本历史
	function doVersionHis(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('流程版本列表','BpmVersionHisList.html?' + 'bpmCode=' + row.bpmCode+'&bpmType='+row.bpmType);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
</script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',title:''" style="height: 40px; ">
	<form id="searchForm">
		<table>
			<tr>
				<td class="searchTd">&nbsp;流程编号：</td>
				<td><input name="bpmCode" id="bpmCode"/></td>
				<td class="searchTd"> 流程名称：</td>
				<td><input name="bpmName" id="bpmName"/></td>
				<td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="queryList()">查找</a></td>
				<td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.clearForm('searchForm');">清空</a></td>
			</tr>
		</table>
	</form>
</div>
<div data-options="region:'center',split:false">
	<table id="dg" class="easyui-datagrid" title="" style="width:100%;height:94%"
		   data-options="singleSelect:true,collapsible:true,method:'post'"
		   toolbar="#tb"
		   rownumbers="true" pagination="true" pageSize="20">
		<thead>
		<tr>
			<th data-options="field:'bpmId',resizable:true" hidden="true" >流程标识</th>
			<th data-options="field:'bpmCode',resizable:true" >流程编号</th>
			<th data-options="field:'bpmName',resizable:true" >流程名称</th>
			<th data-options="field:'equallyTaskAmount',resizable:true" hidden="true" >任务并发数</th>
			<th data-options="field:'isRunAgain',resizable:true" formatter="formatter_STD_PUB_YN">是否允许重跑</th>
			<th data-options="field:'bpmVersion',resizable:true" >流程版本</th>
			<th data-options="field:'subsCode',resizable:true" hidden="true">子系统代码</th>
			<th data-options="field:'effectState',resizable:true" formatter="formatter_STD_PUB_YN">是否生效</th>
			<th data-options="field:'latestState',resizable:true" formatter="formatter_STD_PUB_YN">是否最新版本</th>
			<th data-options="field:'createUser',resizable:true" >创建人</th>
			<th data-options="field:'createTime',resizable:true" >创建时间</th>
			<th data-options="field:'lastUpdateUser',resizable:true" >最后更新人</th>
			<th data-options="field:'lastUpdateTime',resizable:true" >最后修改时间</th>
		</tr>
		</thead>
	</table>
</div>
<div id="tb" style="padding:1px">
	<div style="margin-bottom:2px">
		<a href="javascript:doAdd()" class="easyui-linkbutton" iconCls="icon-add" plain="true">新增审批流程</a>
		<a href="javascript:doEdit()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">配置审批流程</a>
		<a href="javascript:doPublish()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">发布审批流程</a>
		<a href="#" class="easyui-menubutton" data-options="menu:'#infoMenu',iconCls:'icon-tip'" plain="true">流程信息管理</a>
		<a href="javascript:bpmTest()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">流程仿真测试</a>
		<a href="javascript:doVersionHis()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">流程版本</a>
	</div>
</div>
<div id="infoMenu" style="width: 150px;">
	<div onclick="javascript:doUpdate()">修改审批流程</div>
	<div onclick="javascript:doDelete()">删除审批流程</div>
	<div onclick="javascript:doView()()">查看审批流程</div>
</div>
</body>
</html>

